<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>新闻列表</title>
<link href="../css/login.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../css/table.css"/>
<script type="text/javascript" src="../js/table.js"></script>
<script type="text/javascript">
	function InitAjax() {
		var ajax = false;
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				ajax = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (E) {
				ajax = false;
			}
		}
		if (!ajax && typeof XMLHttpRequest != "undefined") {
			ajax = new XMLHttpRequest();
		}
		return ajax;
	}
	var req = InitAjax();
	function submitIsUse(isUse,id) {
		var url = "banner.do?op=updateIsUse&isUse="+isUse+"&id="+id;
		if (req) {
			req.open("GET", url, true);
			req.onreadystatechange = callback1;
			req.send(null);
		}
	}
	function callback1() {
		if (req.readyState == 4) {
			if (req.status == 200) {   
	            alert("使用狀態更新成功！");
			} else {
				alert("使用狀態更新失敗! reason:" + req.statusText);
			}
		}
	}
	
	function show(tag,id){
		document.getElementById("bannerInput").value=id;
		var light=document.getElementById(tag);
		var fade=document.getElementById('fade');
		light.style.display='block';
		fade.style.display='block';
		}
	function hide(tag){
		var light=document.getElementById(tag);
		var fade=document.getElementById('fade');
		light.style.display='none';
		fade.style.display='none';
	}
</script>
</head>
<body>
<form action="news-listnews.action" method="post">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="30"><img src="images/tab_03.gif" width="15" height="30" /></td>
        <td width="1101" background="images/tab_05.gif"><img src="images/311.gif" width="16" height="16" /> <span class="STYLE4">新闻管理</span></td>
        <td width="281" background="images/tab_05.gif"><table border="0" align="right" cellpadding="0" cellspacing="0">
            <tr>
              <td width="60"><table width="90%" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td class="STYLE1"><div align="center"><img src="images/001.gif" width="14" height="14" /></div></td>
                    <td class="STYLE1"><div align="center"><a href="addNews.jsp">新增</a></div></td>
                  </tr>
              </table></td>
            </tr>
        </table> </td>
        <td width="14"><img src="images/tab_07.gif" width="14" height="30" /></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="9" background="images/tab_12.gif">&nbsp;</td>
        <td bgcolor="#f3ffe3"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#c0de98" onmouseover="changeto()"  onmouseout="changeback()">
          <tr>
            <td width="2%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">编号</div></td>
            <td width="6%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">新闻标题</div></td>
            <td width="8%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">新闻内容</div></td>
            <td width="8%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">语言类型</div></td>
            <td width="8%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">更新时间</div></td>
            <td width="14%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">首页置顶</div></td>
             <td width="14%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">浏览次数</div></td>
            <td width="7%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">編輯</div></td>
            <td width="7%" height="18" background="images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2">刪除</div></td>
          </tr>
          <c:forEach var="news" items="${list}">
          <tr>
            <td height="18" bgcolor="#FFFFFF" class="STYLE2"><div align="center" class="STYLE2 STYLE1">${news.id }</div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><a href="../news-detail.action?id=${news.id }" target="_blanck">${news.title }</a></div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><a href="../news-detail.action?id=${news.id }" target="_blanck">${news.content }</a></div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><a href="../news-detail.action?id=${news.id }" target="_blanck"><c:if test="${news.type eq 1}">中文</c:if><c:if test="${news.type eq 2}">日文</c:if><c:if test="${news.type eq 3}">英文</c:if></a></div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1">${news.createTime }</div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><c:if test="${news.isOnTop eq 0}">否</c:if><c:if test="${news.isOnTop eq 1}">是</c:if></div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1">${news.viewCount }</div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center"><span class="STYLE2"><img src="images/037.gif" width="9" height="9" /></span><span class="STYLE1"> [</span><a href="news-toUpdate.action?id=${news.id }">编辑</a><span class="STYLE1">]</span></div></td>
            <td height="18" bgcolor="#FFFFFF"><div align="center"><span class="STYLE2"><img src="images/010.gif" width="9" height="9" /></span><span class="STYLE2"> </span><span class="STYLE1">[</span><a href="news-del.action?id=${news.id }" onclick="javascript:return window.confirm('您确认要删除吗?')">刪除</a><span class="STYLE1">]</span></div></td>
          </tr>
          </c:forEach>
        </table></td>
        <td width="9" background="images/tab_16.gif">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="29"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="15" height="29"><img src="images/tab_20.gif" width="15" height="29" /></td>
        <td background="images/tab_21.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            	 <td width="25%" height="29" nowrap="nowrap"></td>
	            <td width="75%" valign="top" class="STYLE1"><div align="right">
	              <table width="352" height="20" border="0" cellpadding="0" cellspacing="0">
	                <tr>
	                  	<td width="62" height="22" valign="middle"><div align="right"><img src="images/first.gif" width="37" height="15" onclick="javascript:first();" /></div></td>
		                  <td width="50" height="22" valign="middle"><div align="right"><img src="images/back.gif" width="43" height="15" onclick="javascript:up();" /></div></td>
		                  <td width="54" height="22" valign="middle"><div align="right"><img src="images/next.gif" width="43" height="15" onclick="javascript:down();" /></div></td>
		                  <td width="49" height="22" valign="middle"><div align="right"><img src="images/last.gif" width="37" height="15" onclick="javascript:last();" /></div></td>
		                  <td width="59" height="22" valign="middle"><div align="right">转到第</div></td>
		                  <td width="25" height="22" valign="middle"><span class="STYLE7">
		                    <input name="page" id="page" value="${page }" type="text" class="STYLE1" style="height:10px; width:25px;" />
		                  </span></td>
		                  <td width="23" height="22" valign="middle">頁</td>
		                  <td width="30" height="22" valign="middle"><img src="images/go.gif" width="37" height="15" onclick="javascript:commit();" /></td>
	                </tr>
	              </table>
	            </div></td>
          </tr>
        </table></td>
        <td width="14"><img src="images/tab_22.gif" width="14" height="29" /></td>
      </tr>
    </table></td>
  </tr>
</table>
</form>
</body>
</html>
<script type="text/javascript">
		var page = document.getElementById("page").value;
		var pageSize = document.getElementById("pageSize").value;
		function up(){
			document.getElementById("page").value = ${page-1};
			document.forms[0].submit();
		}
		function down(){
			document.getElementById("page").value = ${page+1};
			document.forms[0].submit();
		}
		function last(){
			document.getElementById("page").value = ${pageCount};
			document.forms[0].submit();
		}
		function first(){
		    document.getElementById("page").value = 1;
			document.forms[0].submit();
		}
		function commit(){
			document.forms[0].submit();
		}
</script>
